package net.sf.calibur.pool;

import net.sf.calibur.jmx.ManagedBean;

import org.softee.management.annotation.MBean;
import org.softee.management.annotation.ManagedAttribute;

@MBean
public class PooledObjectStatistics implements ManagedBean {
	private ObjectPool pool;
	private Object key;

	public PooledObjectStatistics(ObjectPool pool) {
		this.pool = pool;
		this.key = pool.getKey();
	}

	@Override
	public String getObjectName() {
		String keyStr = key.toString().replace(' ', '_');
		return new StringBuffer("calibur.objectPool:name=").append(keyStr)
				.toString();
	}

	@ManagedAttribute
	public String getKey() {
		return key.toString();
	}

	@ManagedAttribute
	public int getNumActive() {
		return pool.getNumActive();
	}

	@ManagedAttribute
	public int getNumIdle() {
		return pool.getNumIdle();
	}
}